import { _decorator, Collider2D, IPhysics2DContact } from "cc";
import { BaseReward } from "../BaseReward";
import { BaseBullet } from "../BaseBullet";

const { ccclass, property } = _decorator;

@ccclass("Damage")
export class Damage extends BaseReward {
  @property
  damageIncrease: number = 1;

  protected onBeginContact(
    selfCollider: Collider2D,
    otherCollider: Collider2D,
    contact: IPhysics2DContact | null
  ) {
    // 检查碰撞对象是否为玩家
    const player = otherCollider.node.getComponent("Player");
    if (player) {
      // 增加子弹伤害
      BaseBullet.damage += this.damageIncrease;
    }
  }
}
